<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box {
            width: 100px;
            height: 100px;
            border: 1px solid red;
            margin-top: 50px;
            background-color: aqua;
        }
    </style>
</head>

<body>
    <div id="box"></div>
    <script>
        /**
         * 作用：给元素的某个属性赋值
         * @param: ele 元素
         * @param: attr 属性
         * @param: value 属性值
         */

        function setCss(ele, attr, value) {
            ele.style[attr] = value;
        }
        var oBox = document.getElementById('box');
        setCss(oBox, 'width', '400px');
        setCss(oBox, 'height', '800px');
        setCss(oBox, 'backgroundColor', 'red');


        
    </script>
</body>

</html>